<template>
	<view class="add-bank-card">
		<NavBar title="新增收货地址" :isBack="true"></NavBar>
		<view class="content">
			<view class="card-info">
				<view class="row card-name">
					<view class="title">收件人：</view>
					<input type="text" placeholder="收货人姓名" v-model="addressInfo.name">
				</view>
				<view class="row card-name">
					<view class="title">联系电话：</view>
					<input type="text" placeholder="收货人手机号" v-model="addressInfo.mobile">
				</view>
				<view class="row card-name">
					<view class="title">收件地址：</view>
					<input type="text" placeholder="选择省/市/区" v-model="addressInfo.area">
				</view>
				<view class="row">
					<view class="title">详细地址：</view>
					<input type="text" placeholder="街道门牌/楼层房间号等信息" v-model="addressInfo.address">
				</view>
			</view>
			<view class="verify-btn" @click="handleSave">
				保存
			</view>
		</view>

	</view>
</template>

<script setup>
import { addRessinser } from '@/api/address.js'
import { onMounted, reactive, toRefs } from 'vue'
import { showToast } from '@/common/interactiveFeedback.js'

const state = reactive({
	addressInfo: {
		name: "",
		mobile: "",
		address: "",
	}
})

async function handleSave () {
	// if (Object.values(state.addressInfo).includes("")) return showToast("地址信息不能为空")
	const res = await addRessinser(state.addressInfo)
	if (res.code) {
		showToast("添加成功")
		uni.navigateBack()
	}
}
const { addressInfo } = toRefs(state)
</script>

<style lang="scss" scoped>
.add-bank-card {
	.content {
		position: relative;
		z-index: 1;
		padding: 36rpx;

		.card-info {
			width: 678rpx;
			background: #FFFFFF;
			border-radius: 22rpx 22rpx 22rpx 22rpx;
			padding: 36rpx 27rpx;
			box-sizing: border-box;

			.card-name {
				border-bottom: 1rpx solid #F5F5F5;
				padding-bottom: 24rpx;
				margin-bottom: 38rpx;
			}

			.row {
				position: relative;
				display: flex;
				align-items: center;
				font-weight: bold;
				font-size: 26rpx;
				color: #333333;

				.title {
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;
					margin-right: 32rpx;
					width: 150rpx;
					text-align: right;
				}

				input {
					font-weight: 500;
					font-size: 26rpx;
					color: #333333;
					width: 70%;
				}

				.doubt {
					width: 26rpx;
					height: 26rpx;
					position: absolute;
					right: 0rpx;
				}
			}
		}

		.hint {
			font-weight: bold;
			font-size: 18rpx;
			color: #999999;
			margin: 44rpx 0rpx 15rpx;
		}

		.verify-btn {
			text-align: center;
			width: 648rpx;
			height: 66rpx;
			line-height: 66rpx;
			background: #58DBCF;
			border-radius: 500rpx 500rpx 500rpx 500rpx;
			font-weight: 800;
			font-size: 30rpx;
			color: #FFFFFF;
			margin-top: 84rpx;
		}
	}

}
</style>